import * as TYPES from './actionTypes';
import {InvoiceUrl,InvoiceUpdateUrl} from '../../Component/common/url';

// get
export function InvoiceGet(token){
	return (dispatch) => {
		let order_all = fetch(InvoiceUrl,{
				method: "POST",
				headers: {
					"Content-Type": "application/json",
					"Authorization": "Bearer "+token
				},
				//body:JSON.stringify({orderId:orderid})
			})
			.then(response=>response.json())
			.then((data)=>{
				dispatch({'type': TYPES.INVOICE_GET, invoice: data});
			}).catch((e)=>{
				console.log(e.message);
				//dispatch({'type': TYPES.SIGN_ERRER, error: e});
			});
	}
}

// update
export function InvoiceUpdate(token,opt){
	return (dispatch) => {
		let order_all = fetch(InvoiceUpdateUrl,{
				method: "POST",
				headers: {
					"Content-Type": "application/json",
					"Authorization": "Bearer "+token
				},
				body:JSON.stringify(opt)
			})
			.then(response=>response.json())
			.then((data)=>{
				//dispatch({'type': TYPES.INVOICE_GET, invoice: data});
			}).catch((e)=>{
				console.log(e.message);
				//dispatch({'type': TYPES.SIGN_ERRER, error: e});
			});
	}
}


